<template>
  <view class="page_root" data-page-name="我的日报（定制）" data-page-identification="e_lxijxliaea">
    <!-- UNI_APP_EXEGESIS_START NAVIGATION_TEMPLATE UNI_APP_EXEGESIS_END -->
    <!-- begin vid_yudkkk9rv0 自定义模板_691g4fzofs -->
    <u-navbar
      back-icon-color="#fff"
      title="我的日报"
      title-color="#fff"
      :border-bottom="false"
      title-width="350"
    >
    </u-navbar>
    <u-mask :show="recordState.loadingShow" @click="show = false">
      <view
        style="
          height: 100px;
          width: 100px;
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
        "
      >
        <u-loading
          :color="'red'"
          mode="semicircle"
          textSize="50"
          :show="recordState.loadingShow"
          size="100"
        ></u-loading>
        <view v-if="recordState.loadingShow" style="color: #fff">正在提交....</view>
      </view>
    </u-mask>
    <u-picker
      v-model="recordState.dateShow"
      mode="time"
      @confirm="onConfirm"
      @cancel="onCancel"
    ></u-picker>
    <view class="record-date" @click="changeDate">
      <view class="date-left">{{ recordState.selectedDate }}</view>
      <view class="date-right"><u-icon name="calendar" size="32"></u-icon></view>
    </view>
    <view class="main">
      <view class="record-content" v-for="(item, index) in recordState.recordList">
        <view class="content-box-top">
          <view class="top-left">
            <view class="daily-type">{{ typeMap[item.dailyType] }} </view>
            <view class="daily-status">{{ item.status }} </view>
          </view>
          <view
            class="daily-delete"
            v-if="item.status !== '已提交'"
            @click="deleteRecord(item.dailyItemId)"
            >删除</view
          >
        </view>
        <view class="content-item">
          <view
            class="item-bottom-title"
            v-if="item.dailyType === '1' || item.dailyType === '4' || item.dailyType === '5'"
          >
            <span class="work-title">项目名称：</span
            ><span class="bottom-work-num">{{ item.projectCode }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '6'">
            <span class="work-title">工单标题：</span
            ><span class="bottom-work-num">{{ item.projectCode }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '1'">
            <span class="work-title">项目阶段：</span
            ><span class="bottom-work-num">{{ item.milepostName }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '1'">
            <span class="work-title">任务：</span
            ><span class="bottom-work-num">{{ item.taskName }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '3'">
            <span class="work-title">工作类型：</span
            ><span class="bottom-work-num">{{ item.projectCode }}</span>
          </view>
          <view class="item-bottom-title">
            <span class="work-title">工时：</span
            ><span class="bottom-work-num">{{ item.workingHours }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '1'">
            <span class="work-title">是否存在风险：</span
            ><span class="bottom-work-num">{{ item.risk }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '1'">
            <span class="work-title">风险描述：</span
            ><span class="bottom-work-num">{{ item.riskDescription }}</span>
          </view>
          <view class="item-bottom-title" v-if="item.dailyType === '1'">
            <span class="work-title">解决方案：</span
            ><span class="bottom-work-num">{{ item.solution }}</span>
          </view>
          <view class="item-bottom-title">
            <span class="work-title">提交时间：</span
            ><span class="bottom-work-num">{{ item.submissionTime }}</span>
          </view>
        </view>
      </view>

      <view class="no-data" v-if="recordState.recordList.length == 0">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          xmlns:xlink="http://www.w3.org/110/xlink"
          width="80.5px"
          height="80.25px"
          viewBox="0 0 80.5 80.25"
          version="1.1"
        >
          <title>编组 7备份 2@1x备份 17@2x</title>
          <g id="首页" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
            <g id="我的日报-暂无数据" transform="translate(-146.75, -353.75)" fill-rule="nonzero">
              <g id="状态:60/异常态/查找失败" transform="translate(147, 354)">
                <path
                  d="M40,0 C62.0913902,0 80,18.0469004 80,40.3088803 C80,52.1884083 74.90044,62.8676728 66.7869871,70.2449022 L66.7870258,23.9023654 L58.7170124,15.3424481 L19.9769259,15.3424481 C17.8357604,15.3424481 16.1000028,17.0937168 16.1000028,19.2540163 L16.1000028,19.2540163 L16.1000028,71.1249467 C16.1000028,71.7943041 16.2666419,72.4243926 16.5603472,72.975286 C6.52666492,65.6514397 0,53.7482377 0,40.3088803 C0,18.0469004 17.90861,0 40,0 Z"
                  id="形状结合"
                  stroke-opacity="0.3"
                  stroke="#FFFFFF"
                  stroke-width="0.5"
                  fill-opacity="0.25"
                  fill="#9FA0A0"
                />
                <g
                  id="objects/element/paper2"
                  transform="translate(10.2873, 11.0893)"
                  fill="#C6C6C6"
                  fill-opacity="0.8"
                >
                  <path
                    d="M6.29206351,6.27042383 C5.98433011,6.83031266 5.80877986,7.47442445 5.80794968,8.1598946 L5.80794968,8.1598946 L5.76378148,44.2541611 L0.0584376437,11.2924326 C-0.309902709,9.16433874 1.10137946,7.13791062 3.2106246,6.76627874 C3.22963081,6.76293 3.24866153,6.75972444 3.26771517,6.75666237 L6.29206351,6.27042383 Z M49.4425483,3.29684597 C49.4477443,3.3297585 49.4525232,3.36273668 49.4568838,3.39577244 L49.7557815,5.65940106 L48.4296908,4.25310614 L18.8443969,4.25309918 L45.0040422,0.0492732256 C47.1185513,-0.29054669 49.1057381,1.16344115 49.4425483,3.29684597 Z"
                    id="形状结合"
                    stroke-opacity="0.3"
                    stroke="#FFFFFF"
                    stroke-width="0.5"
                  />
                  <path
                    d="M30.2251216,38.2391328 C31.1557284,38.2391328 31.9101342,39.0002802 31.9101342,39.939203 C31.9101342,40.8781259 31.1557284,41.6392733 30.2251216,41.6392733 L12.7796457,41.6392733 C11.849039,41.6392733 11.0946331,40.8781259 11.0946331,39.939203 C11.0946331,39.0002802 11.849039,38.2391328 12.7796457,38.2391328 L30.2251216,38.2391328 Z M45.7249879,28.8387445 C46.6555947,28.8387445 47.4100005,29.5998919 47.4100005,30.5388147 C47.4100005,31.4777376 46.6555947,32.2388849 45.7249879,32.2388849 L12.7796457,32.2388849 C11.849039,32.2388849 11.0946331,31.4777376 11.0946331,30.5388147 C11.0946331,29.5998919 11.849039,28.8387445 12.7796457,28.8387445 L45.7249879,28.8387445 Z M45.7249879,19.4383561 C46.6555947,19.4383561 47.4100005,20.1995035 47.4100005,21.1384264 C47.4100005,22.0773492 46.6555947,22.8384966 45.7249879,22.8384966 L12.7796457,22.8384966 C11.849039,22.8384966 11.0946331,22.0773492 11.0946331,21.1384264 C11.0946331,20.1995035 11.849039,19.4383561 12.7796457,19.4383561 L45.7249879,19.4383561 Z M34.2251216,10.0379678 C35.1557284,10.0379678 35.9101342,10.7991151 35.9101342,11.738038 C35.9101342,12.6769609 35.1557284,13.4381082 34.2251216,13.4381082 L12.7796457,13.4381082 C11.849039,13.4381082 11.0946331,12.6769609 11.0946331,11.738038 C11.0946331,10.7991151 11.849039,10.0379678 12.7796457,10.0379678 L34.2251216,10.0379678 Z"
                    id="形状结合备份-2"
                  />
                  <path
                    d="M56.4997042,12.8130234 L51.1503166,12.8130234 C49.7228729,12.8130234 48.5657012,11.645511 48.5657012,10.2053113 L48.5657012,4.25310614 L56.4997042,12.8130234 Z"
                    id="路径-23备份"
                  />
                </g>
                <g id="objects/element/-readingglass备份" transform="translate(40.4354, 45.7399)">
                  <path
                    d="M13.4003706,0 C20.8011909,0 26.8007412,5.94769509 26.8007412,13.2845488 C26.8007412,16.7662885 25.4496285,19.9351865 23.2388252,22.3040679 L25.5414528,24.5845909 C26.0416407,24.4553201 26.5941386,24.5861382 26.9884562,24.9770477 L32.7112193,30.6503273 C33.3113025,31.2452446 33.3197787,32.2183311 32.7301409,32.8237873 L32.7112191,32.8428987 L31.7261781,33.8194055 C31.1335292,34.406932 30.1835599,34.406932 29.590911,33.8194055 L23.86817,28.1461489 C23.4733235,27.7547016 23.3346108,27.1995275 23.4538855,26.6930843 L20.981757,24.2401049 C18.8257172,25.709241 16.2143345,26.5690976 13.4003706,26.5690976 C5.1055026,26.5690976 0,20.6214025 0,13.2845488 C0,5.94769509 5.1055026,0 13.4003706,0 Z M13.4003706,2.95212195 C7.64417698,2.95212195 2.97786013,7.578107 2.97786013,13.2845488 C2.97786013,18.9909906 7.64417698,23.6169757 13.4003706,23.6169757 C19.1565641,23.6169757 23.822881,18.9909906 23.822881,13.2845488 C23.822881,7.578107 19.1565641,2.95212195 13.4003706,2.95212195 Z"
                    id="形状结合"
                    fill-opacity="0.8"
                    fill="#C6C6C6"
                  />
                  <path
                    d="M19.9400878,11.666347 L20.049955,11.7752647 C20.2065012,11.9304578 20.2087124,12.1843065 20.0548938,12.3422516 C20.0532621,12.3439271 20.0516158,12.3455881 20.049955,12.3472345 L17.2326532,15.140186 C17.0780491,15.2934537 16.830231,15.2934537 16.675627,15.140186 L16.5657596,15.0312683 C16.4092135,14.8760751 16.4070023,14.6222265 16.5608209,14.4642814 C16.5624526,14.4626059 16.564099,14.4609448 16.5657596,14.4592985 L19.3830615,11.666347 C19.5376656,11.5130793 19.7854837,11.5130793 19.9400878,11.666347 Z"
                    id="矩形"
                    fill-opacity="0.6"
                    fill="#9FA0A0"
                  />
                  <path
                    d="M22.312129,11.9383854 L22.534806,12.1591379 C22.6913522,12.314331 22.6935634,12.5681796 22.5397448,12.7261247 C22.538113,12.7278002 22.5364667,12.7294613 22.534806,12.7311076 L17.1228793,18.0962581 C16.9682753,18.2495259 16.7204572,18.2495259 16.5658531,18.0962581 L16.343176,17.8755057 C16.1866298,17.7203126 16.1844187,17.4664639 16.3382372,17.3085188 C16.339869,17.3068433 16.3415153,17.3051822 16.343176,17.3035359 L21.7551028,11.9383854 C21.9097068,11.7851176 22.1575249,11.7851176 22.312129,11.9383854 Z"
                    id="矩形"
                    fill-opacity="0.6"
                    fill="#9FA0A0"
                  />
                </g>
              </g>
            </g>
          </g>
        </svg>
        <view class="no-tip">暂无数据</view>
      </view>

      <!-- end vid_q0bo8r9rh5 标签页_zd90mmmi4z -->
    </view>
    <view class="fixed-button" @click="handleSubmit">提交</view>
    <!-- 删除提示 -->
    <view>
      <u-modal
        v-model="recordState.deleteShow"
        content="确认删除这条日报吗？"
        show-cancel-button
        @confirm="handleDeleteRecord(dailyItemId)"
      ></u-modal>
    </view>
    <view>
      <u-toast ref="uToast"></u-toast>
    </view>
    <u-modal
      v-model="subShow"
      show-cancel-button
      @confirm="handleConfirmSubmit"
      title="请确认"
      :title-style="{ padding: 0, marginTop: '10px', marginBottom: '10px' }"
    >
      <view class="sub-tip">
        正在提交工时：{{ editHour }}工时 <br />今日已提交总工时（不含本次提交）：{{ allHours }}工时
      </view>
    </u-modal>
    <!-- end vid_yudkkk9rv0 自定义模板_691g4fzofs -->
  </view>
</template>
<script setup>
  import {
    ref,
    reactive,
    toRaw,
    markRaw,
    watch,
    computed,
    onBeforeMount,
    onMounted,
    onBeforeUnmount,
    onUnmounted,
    onActivated,
    onDeactivated,
    getCurrentInstance,
  } from 'vue';
  import { useRoute } from 'vue-router';
  const route = useRoute();
  import { get, post, put, del, request, requestWithHeaders } from '@/utils/http/Axios';
  import {
    cloneDeep,
    localGet,
    traversalTreeStructure,
    set,
    checkCaseCondition,
    throttle,
    merge,
    debounce,
    getGridStyle,
    getCellRenderAble,
    formulaStrategy,
    getApplicationId,
    getComponentParamsValue,
    get as lodashGet,
  } from '@/utils/index';
  import {
    isEqual,
    isNullOrEmpty,
    isEmptyArr,
    isArray,
    isEmpty,
    isNullOrUnDef,
    isContained,
  } from '@/utils/is';
  import { CovertOptions, getChartsDataSourceConvert } from '@/utils/chart';
  import {
    propertyFormatByNumber,
    propertyFormatByPercentage,
    propertyFormatByDate,
    parseSubFromDataList,
  } from '@/utils/format';
  import { checkCommonCondition, getResultByCurrentCommonCondition } from '@/utils/formCondition';
  import { FormFormat } from '@/utils/formFormat';
  import { customAddWaterMarkFunc, generateWaterMarkText } from '@/utils/addWaterMark';
  import dayjs from 'dayjs';
  import hashSum from 'hash-sum';
  /*** UNI_APP_EXEGESIS ***
  import { handleRedirect, permission, parseJson } from '@/utils/common';
  import { onPullDownRefresh, onLoad, onReady, onShow, onHide, onPageScroll, onUnload } from '@dcloudio/uni-app';
  import { BroadcastMessage } from '@/utils/BroadcastMessage';
  import { sendToken } from "@/hooks/useIframeToken";
  *** UNI_APP_EXEGESIS ***/

  // ---------------------------- 属性定义 ----------------------------
  const sourceId = 'page3000001238';
  import {
    onPullDownRefresh,
    onLoad,
    onReady,
    onShow,
    onHide,
    onPageScroll,
    onUnload,
  } from '@dcloudio/uni-app';
  // 获取传入的流程ID和组件参数
  const props = defineProps({
    processInstanceId: {
      type: [String, Number, Boolean],
      default: undefined,
    },
    hideNav: {
      type: [Boolean],
      default: undefined,
    },
  });

  // 组件参数默认值
  const componentParamsDefaultProps = {};

  // 是否显示菜单按钮
  const isMenuIconShow = false;
  // NAVIGATION_MENU
  const handleShowNavigation = () => {};

  let isProcessState = ref(false);

  const setTimeOutList = [];

  const vid_yudkkk9rv0_props = reactive({
    code: '    <u-mask :show="recordState.loadingShow" @click="show = false">\n      <view style="height: 100px; width: 100px;position: absolute; top: 50%; left: 50%;transform: translate(-50%, -50%);">\n        <u-loading :color="\'red\'" mode="semicircle" textSize="50" :show="recordState.loadingShow" size="100"></u-loading>\n        <view v-if="recordState.loadingShow" style="color: #fff;">正在提交....</view>\n      </view>\n    </u-mask>\n    <view class="main">\n      <u-picker v-model="recordState.dateShow" mode="time" @confirm="onConfirm" @cancel="onCancel"></u-picker>\n      <view class="record-date" @click="changeDate">\n        <view class="date-left">{{ recordState.selectedDate }}</view>\n        <view class="date-right"><u-icon name="calendar" size="32"></u-icon></view>\n      </view>\n      <view class="bgc-img"></view>\n      <view class="bottom-body">\n        <view class="record-body" v-if="recordState.recordList.length > 0">\n          <view class="record-content" v-for=" (item, index) in recordState.recordList ">\n            <view class="content-box-top" v-if="item.dailyType===\'1\' "> 任务日报 </view>\n            <view class="content-box-top" v-if="item.dailyType===\'3\' "> 其他日报 </view>\n            <view class="content-box-top" v-if="item.dailyType===\'4\' "> 项目日报 </view>\n            <view class="content-box-top" v-if="item.dailyType===\'5\' "> 行动项日报 </view>\n            <view class="content-item">\n              <view class="item-bottom-title" v-if="item.dailyType===\'1\' || item.dailyType===\'4\' || item.dailyType===\'5\' ">\n                <span class="work-title">项目名称</span\n                ><span class="bottom-work-num">{{\n                                      item.projectCode }}</span>\n              </view>\n              <view class="item-bottom-title" v-if="item.dailyType===\'1\' ">\n                <span class="work-title">项目阶段：</span\n                ><span class="bottom-work-num">{{\n                                      item.milepostName }}</span>\n              </view>\n              <view class="item-bottom-title" v-if="item.dailyType===\'1\' ">\n                <span class="work-title">任务：</span\n                ><span class="bottom-work-num">{{\n                                      item.taskName }}</span>\n              </view>\n              <view class="item-bottom-title" v-if="item.dailyType===\'3\' ">\n                <span class="work-title">工作类型：</span\n                ><span class="bottom-work-num">{{\n                                      item.projectCode }}</span>\n              </view>\n              <view class="item-bottom-title">\n                <span class="work-title">工时：</span\n                ><span class="bottom-work-num">{{\n                                      item.workingHours }}</span>\n              </view>\n              <view class="item-bottom-title" v-if="item.dailyType===\'1\' ">\n                <span class="work-title">是否存在风险：</span\n                ><span class="bottom-work-num">{{\n                                      item.risk }}</span>\n              </view>\n              <view class="item-bottom-title" v-if="item.dailyType===\'1\' ">\n                <span class="work-title">风险描述：</span\n                ><span class="bottom-work-num">{{\n                                      item.riskDescription }}</span>\n              </view>\n              <view class="item-bottom-title" v-if="item.dailyType===\'1\' ">\n                <span class="work-title">解决方案：</span\n                ><span class="bottom-work-num">{{\n                                      item.solution }}</span>\n              </view>\n              <view class="item-bottom-title">\n                <span class="work-title">提交时间：</span\n                ><span class="bottom-work-num">{{\n                                      item.submissionTime }}</span>\n              </view>\n              <view class="bottom-content">\n                <view class="record-tag">\n                  <view v-if="item.status === \'已通过\'">\n                    <view class="success-status">已通过</view>\n                  </view>\n                  <view v-else-if="item.status === \'已提交\'">\n                    <view class="ok-status">已提交</view>\n                  </view>\n                  <view v-else-if="item.status === \'未提交\'">\n                    <view class="no-confirm">未提交</view>\n                  </view>\n                  <view v-else-if="item.status === \'被驳回\'">\n                    <view class="error-status">被驳回</view>\n                  </view>\n                </view>\n                <view class="delete-btn" @click="deleteRecord(item.dailyItemId)">删除</view>\n              </view>\n            </view>\n          </view>\n        </view>\n        <view class="no-data" v-else>\n          <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/110/xlink" width="80.5px" height="80.25px" viewBox="0 0 80.5 80.25" version="1.1">\n            <title>编组 7备份 2@1x备份 17@2x</title>\n            <g id="首页" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n              <g id="我的日报-暂无数据" transform="translate(-146.75, -353.75)" fill-rule="nonzero">\n                <g id="状态:60/异常态/查找失败" transform="translate(147, 354)">\n                  <path\n                    d="M40,0 C62.0913902,0 80,18.0469004 80,40.3088803 C80,52.1884083 74.90044,62.8676728 66.7869871,70.2449022 L66.7870258,23.9023654 L58.7170124,15.3424481 L19.9769259,15.3424481 C17.8357604,15.3424481 16.1000028,17.0937168 16.1000028,19.2540163 L16.1000028,19.2540163 L16.1000028,71.1249467 C16.1000028,71.7943041 16.2666419,72.4243926 16.5603472,72.975286 C6.52666492,65.6514397 0,53.7482377 0,40.3088803 C0,18.0469004 17.90861,0 40,0 Z"\n                    id="形状结合"\n                    stroke-opacity="0.3"\n                    stroke="#FFFFFF"\n                    stroke-width="0.5"\n                    fill-opacity="0.25"\n                    fill="#9FA0A0"\n                  />\n                  <g id="objects/element/paper2" transform="translate(10.2873, 11.0893)" fill="#C6C6C6" fill-opacity="0.8">\n                    <path\n                      d="M6.29206351,6.27042383 C5.98433011,6.83031266 5.80877986,7.47442445 5.80794968,8.1598946 L5.80794968,8.1598946 L5.76378148,44.2541611 L0.0584376437,11.2924326 C-0.309902709,9.16433874 1.10137946,7.13791062 3.2106246,6.76627874 C3.22963081,6.76293 3.24866153,6.75972444 3.26771517,6.75666237 L6.29206351,6.27042383 Z M49.4425483,3.29684597 C49.4477443,3.3297585 49.4525232,3.36273668 49.4568838,3.39577244 L49.7557815,5.65940106 L48.4296908,4.25310614 L18.8443969,4.25309918 L45.0040422,0.0492732256 C47.1185513,-0.29054669 49.1057381,1.16344115 49.4425483,3.29684597 Z"\n                      id="形状结合"\n                      stroke-opacity="0.3"\n                      stroke="#FFFFFF"\n                      stroke-width="0.5"\n                    />\n                    <path\n                      d="M30.2251216,38.2391328 C31.1557284,38.2391328 31.9101342,39.0002802 31.9101342,39.939203 C31.9101342,40.8781259 31.1557284,41.6392733 30.2251216,41.6392733 L12.7796457,41.6392733 C11.849039,41.6392733 11.0946331,40.8781259 11.0946331,39.939203 C11.0946331,39.0002802 11.849039,38.2391328 12.7796457,38.2391328 L30.2251216,38.2391328 Z M45.7249879,28.8387445 C46.6555947,28.8387445 47.4100005,29.5998919 47.4100005,30.5388147 C47.4100005,31.4777376 46.6555947,32.2388849 45.7249879,32.2388849 L12.7796457,32.2388849 C11.849039,32.2388849 11.0946331,31.4777376 11.0946331,30.5388147 C11.0946331,29.5998919 11.849039,28.8387445 12.7796457,28.8387445 L45.7249879,28.8387445 Z M45.7249879,19.4383561 C46.6555947,19.4383561 47.4100005,20.1995035 47.4100005,21.1384264 C47.4100005,22.0773492 46.6555947,22.8384966 45.7249879,22.8384966 L12.7796457,22.8384966 C11.849039,22.8384966 11.0946331,22.0773492 11.0946331,21.1384264 C11.0946331,20.1995035 11.849039,19.4383561 12.7796457,19.4383561 L45.7249879,19.4383561 Z M34.2251216,10.0379678 C35.1557284,10.0379678 35.9101342,10.7991151 35.9101342,11.738038 C35.9101342,12.6769609 35.1557284,13.4381082 34.2251216,13.4381082 L12.7796457,13.4381082 C11.849039,13.4381082 11.0946331,12.6769609 11.0946331,11.738038 C11.0946331,10.7991151 11.849039,10.0379678 12.7796457,10.0379678 L34.2251216,10.0379678 Z"\n                      id="形状结合备份-2"\n                    />\n                    <path\n                      d="M56.4997042,12.8130234 L51.1503166,12.8130234 C49.7228729,12.8130234 48.5657012,11.645511 48.5657012,10.2053113 L48.5657012,4.25310614 L56.4997042,12.8130234 Z"\n                      id="路径-23备份"\n                    />\n                  </g>\n                  <g id="objects/element/-readingglass备份" transform="translate(40.4354, 45.7399)">\n                    <path\n                      d="M13.4003706,0 C20.8011909,0 26.8007412,5.94769509 26.8007412,13.2845488 C26.8007412,16.7662885 25.4496285,19.9351865 23.2388252,22.3040679 L25.5414528,24.5845909 C26.0416407,24.4553201 26.5941386,24.5861382 26.9884562,24.9770477 L32.7112193,30.6503273 C33.3113025,31.2452446 33.3197787,32.2183311 32.7301409,32.8237873 L32.7112191,32.8428987 L31.7261781,33.8194055 C31.1335292,34.406932 30.1835599,34.406932 29.590911,33.8194055 L23.86817,28.1461489 C23.4733235,27.7547016 23.3346108,27.1995275 23.4538855,26.6930843 L20.981757,24.2401049 C18.8257172,25.709241 16.2143345,26.5690976 13.4003706,26.5690976 C5.1055026,26.5690976 0,20.6214025 0,13.2845488 C0,5.94769509 5.1055026,0 13.4003706,0 Z M13.4003706,2.95212195 C7.64417698,2.95212195 2.97786013,7.578107 2.97786013,13.2845488 C2.97786013,18.9909906 7.64417698,23.6169757 13.4003706,23.6169757 C19.1565641,23.6169757 23.822881,18.9909906 23.822881,13.2845488 C23.822881,7.578107 19.1565641,2.95212195 13.4003706,2.95212195 Z"\n                      id="形状结合"\n                      fill-opacity="0.8"\n                      fill="#C6C6C6"\n                    />\n                    <path\n                      d="M19.9400878,11.666347 L20.049955,11.7752647 C20.2065012,11.9304578 20.2087124,12.1843065 20.0548938,12.3422516 C20.0532621,12.3439271 20.0516158,12.3455881 20.049955,12.3472345 L17.2326532,15.140186 C17.0780491,15.2934537 16.830231,15.2934537 16.675627,15.140186 L16.5657596,15.0312683 C16.4092135,14.8760751 16.4070023,14.6222265 16.5608209,14.4642814 C16.5624526,14.4626059 16.564099,14.4609448 16.5657596,14.4592985 L19.3830615,11.666347 C19.5376656,11.5130793 19.7854837,11.5130793 19.9400878,11.666347 Z"\n                      id="矩形"\n                      fill-opacity="0.6"\n                      fill="#9FA0A0"\n                    />\n                    <path\n                      d="M22.312129,11.9383854 L22.534806,12.1591379 C22.6913522,12.314331 22.6935634,12.5681796 22.5397448,12.7261247 C22.538113,12.7278002 22.5364667,12.7294613 22.534806,12.7311076 L17.1228793,18.0962581 C16.9682753,18.2495259 16.7204572,18.2495259 16.5658531,18.0962581 L16.343176,17.8755057 C16.1866298,17.7203126 16.1844187,17.4664639 16.3382372,17.3085188 C16.339869,17.3068433 16.3415153,17.3051822 16.343176,17.3035359 L21.7551028,11.9383854 C21.9097068,11.7851176 22.1575249,11.7851176 22.312129,11.9383854 Z"\n                      id="矩形"\n                      fill-opacity="0.6"\n                      fill="#9FA0A0"\n                    />\n                  </g>\n                </g>\n              </g>\n            </g>\n          </svg>\n          <view class="no-tip">暂无数据</view>\n        </view>\n      </view>\n\n      <!-- end vid_q0bo8r9rh5 标签页_zd90mmmi4z -->\n    </view>\n    <view class="fixed-button" @click="handleSubmit">提交</view>\n    <!-- 删除提示 -->\n    <view>\n      <u-modal v-model="recordState.deleteShow" content="确认删除这条日报吗？" show-cancel-button @confirm="handleDeleteRecord(dailyItemId)"></u-modal>\n    </view>\n    <view>\n      <u-toast ref="uToast"></u-toast>\n    </view>\n    <u-modal v-model="subShow" show-cancel-button @confirm="handleConfirmSubmit" title="请确认" :title-style="{padding:0,marginTop:\'10px\',marginBottom:\'10px\'}">\n      <view class="sub-tip">\n        <view class="sub-title"> 正在提交工时：{{editHour}}工时 <br />今日已提交总工时（不含本次提交）：{{allHours}}工时</view>\n      </view>\n    </u-modal>',
  });

  // ============================ 属性定义 ============================

  // ---------------------------- 元素数据引用 ----------------------------
  // 组件 自定义模板_691g4fzofs ref 的引用
  const vid_yudkkk9rv0_ref = ref(null);
  // 动态key的map
  const fieldTypeMap = {};
  // 动态key的map
  const refMap = { vid_yudkkk9rv0_ref };

  const showState = reactive({
    vid_yudkkk9rv0_visible: true,
  });
  // ============================ 元素数据引用 ============================

  // ---------------------------- 数据 ----------------------------

  // ============================ 数据 ============================

  // ---------------------------- 方法 ----------------------------
  // ---------------------------- 页面数据 ----------------------------

  // ============================ 页面数据 ============================

  // ---------------------------- 数据字典 ----------------------------

  // ============================ 数据字典 ============================

  // ---------------------------- 响应 ----------------------------

  // ============================ 响应 ============================

  // ---------------------------- 函数 ----------------------------

  // 自定义函数 返回上一页
  const customFunction_goBack_ad9asvjxpv = (params) => {
    uni.navigateBack();
  };

  // ============================ 函数 ============================

  // ---------------------------- 页面参数 ----------------------------

  const pageParameter_state = reactive({
    processInstanceId: undefined,
  });

  // ============================ 页面参数 ============================

  // ---------------------------- 组件事件处理方法 ----------------------------

  // ============================ 组件事件处理方法 ============================

  // ============================ 方法 ============================

  // ---------------------------- 生命周期 ----------------------------
  /*** UNI_APP_EXEGESIS ***
      // 获取上一层传递的数据
      const workflowChannel = new BroadcastMessage('WORKFLOW');
      workflowChannel.publish({ status: 'Ready' });
      workflowChannel.subscribe((data) => {
        if (data) {
          isProcessState.value = (window.self !== window.parent && data.type === 'hideHeader');
        }
      });
      *** UNI_APP_EXEGESIS ***/

  const pageScrollTop = ref(0);

  // *** PREVIEW_EXEGESIS ***
  onMounted(() => {
    setPageParams(route.query);
    // 设置表单的rule
    try {
    } catch {
      // do nothing
    }
  });
  // *** PREVIEW_EXEGESIS *** //

  /*** UNI_APP_EXEGESIS ***
  const routeOption = ref({})
  onLoad((option) => {
    routeOption.value = option;
  });
  onReady(() => {
    setPageParams(routeOption.value)
    // 设置表单的rule
    try{

    }catch{
        // do nothing
    }
  });
  // 图表刷新标记
  const uChartsReshowFlag = ref(false);
  onHide(() => { // 页面隐藏后标记置为false(如果不置为false无法触发图表更新)
      uChartsReshowFlag.value = false
  })
  onShow(() => {
      uChartsReshowFlag.value = true; // 页面激活后,标记置为true

      setPageParams(routeOption.value)
  })
  onPageScroll(e => {
      pageScrollTop.value = e.scrollTop
  });
  *** UNI_APP_EXEGESIS ***/

  let setPageParams = (routerParam) => {
    const pageParams = [{ dataType: 'STRING', name: 'processInstanceId' }];
    const strategyMap = {
      STRING: (param, paramValue) => {
        pageParameter_state[param.name] = paramValue;
      },
      BOOLEAN: (param, paramValue) => {
        if ('true' === (paramValue || '').toLowerCase()) {
          pageParameter_state[param.name] = true;
        } else if ('false' === (paramValue || '').toLowerCase()) {
          pageParameter_state[param.name] = false;
        } else {
          // TODO: 是否要支持toast
          console.error('参数传入错误！类型不匹配！');
        }
      },
      NUMBER: (param, paramValue) => {
        if (!isNaN(paramValue)) {
          pageParameter_state[param.name] = Number(paramValue);
        } else {
          // TODO: 是否要支持toast
          console.error('参数传入错误！类型不匹配！');
        }
      },
      ARRAY: (param, paramValue) => {
        if (isNullOrUnDef(paramValue) || !paramValue || paramValue === 'undefined') {
          // default value
          pageParameter_state[param.name] = [];
        } else if (paramValue.trim().startsWith('[') && paramValue.trim().endsWith(']')) {
          try {
            pageParameter_state[param.name] = JSON.parse(decodeURI(paramValue));
          } catch (error) {
            console.error('参数解析失败 ', error);
          }
        } else {
          console.error('参数传入错误！类型不匹配！');
        }
      },
    };
    pageParams.forEach((param) => {
      strategyMap[param.dataType](param, routerParam[param.name]);
    });
  };

  onUnmounted(() => {
    // 销毁定时器
    setTimeOutList.forEach(({ repeat, timer }) => {
      repeat ? clearInterval(timer) : clearTimeout(timer);
    });
  });

  /*** UNI_APP_EXEGESIS ***
  onPullDownRefresh(() => {
    // 下拉刷新
    setTimeout(() => {
        uni.stopPullDownRefresh()
    }, 1000)
  })
  *** UNI_APP_EXEGESIS ***/

  // ============================ 生命周期 ============================

  // ---------------------------- 数据关联处理 ----------------------------
  // ---------------------------- 组件数据同步 ----------------------------

  // ============================ 组件数据同步 ============================
  //
  // ============================ 数据关联处理 ============================

  // ---------------------- 不同组件自定义的处理逻辑 ---------------------

  // ====================== 不同组件自定义的处理逻辑 ======================

  // ================================定制化逻辑========================================
  import { nextTick } from 'vue';
  import { onBeforeRouteLeave } from 'vue-router';
  onMounted(() => {
    setPageStyle('wdrb-page');
  });
  function setPageStyle(newClass) {
    // #ifdef H5
    // 仅在 H5 执行
    const appDiv = document.querySelector('#app');
    if (appDiv) {
      appDiv.className = '';

      if (newClass) {
        appDiv.classList.add(newClass);
      }
    }

    const topHeader = document.querySelector('.uni-page-head');
    if (topHeader) topHeader.remove();

    const wrapper = document.querySelector('uni-page-wrapper');
    if (wrapper) wrapper.style.height = '100%';
    // #endif

    // #ifdef MP
    // 小程序端执行（如果你要做兼容逻辑，可以写这里）
    console.log('当前是小程序环境，不需要处理头部或背景');
    // #endif
  }
  onShow(async () => {
    await getUserInfo();
    getRecordData();
  });
  const recordState = reactive({
    dateShow: false,
    selectedDate: null,
    recordList: [],
    deleteShow: false,
    deleteId: null,
    formattedDate: null,
    productId: null,
    phoneType: null,
    loadingShow: false,
    userInfo: {},
  });

  // 选择日期
  function changeDate() {
    recordState.dateShow = true;
  }
  // 日期确认
  function onConfirm(params) {
    console.log(params, 'params ');
    recordState.selectedDate = `${params.year}-${params.month}-${params.day}`;
    getRecordData();
  }
  // 删除日报
  function deleteRecord(dailyItemId) {
    console.log(dailyItemId, 'dailyItemId');
    recordState.deleteShow = true;
    recordState.deleteId = dailyItemId;
  }
  function handleDeleteRecord() {
    put(`/solution-ppm/api/v2/built-in-system-ppm/daily/${recordState.deleteId}`).then((data) => {
      if (data.code === 200) {
        uni.showToast({
          title: '删除成功',
          icon: 'success',
        });
        getRecordData();
        recordState.deleteShow = false;
      } else {
        uni.showToast({
          title: '删除失败',
          icon: 'error',
        });
        recordState.deleteShow = false;
      }
    });
  }
  // 提交
  function handleSubmit() {
    subShow.value = true;
    editHour.value = recordState.recordList
      .filter((item) => item.status === '未提交')
      .reduce((sum, item) => sum + item.workingHours, 0);
    console.log(editHour.value);
  }
  async function handleConfirmSubmit() {
    recordState.loadingShow = true;
    try {
      const result = await post(
        '/solution-ppm/api/v2/built-in-system-ppm/daily/weChat/approval-process',
      );

      if (result.code === 200) {
        uni.showToast({
          title: '提交成功',
          icon: 'success',
        });
        await getRecordData();
      } else {
        uni.showToast({
          title: '提交失败',
          icon: 'error',
        });
        await getRecordData();
      }
    } catch (error) {
      // 请求失败，处理错误
      uni.showToast({
        title: '提交失败',
        icon: 'error',
      });
    } finally {
      // 无论成功或失败，都在这里重新启用提交按钮
      recordState.loadingShow = false;
      subShow.value = false; // 启用提交按钮
    }
  }
  async function getUserInfo() {
    await get('/base/api/v1/user/userinfo').then((data) => {
      if (data.status !== 'success') {
        recordState.userInfo = {};
        return;
      }
      recordState.userInfo = data.data.userItem;
      return data.data.userItem;
    });
  }
  async function getRecordData() {
    recordState.loadingShow = true;
    try {
      const currentDate = dayjs().format('YYYY-MM-DD');

      recordState.formattedDate = currentDate;
      recordState.selectedDate = recordState.selectedDate
        ? recordState.selectedDate
        : recordState.formattedDate;


      const data = await post('/solution-ppm/api/v2/built-in-system-ppm/daily/list', {
        dateOption: [recordState.selectedDate,recordState.selectedDate],
        pageSize: 9999,
        pageNo: 1,
        reportedBy: recordState.userInfo.name || '杜',
      });
      console.log(data.status, 'data.status');
      recordState.recordList = data.data.dataList;
      post('/solution-ppm/api/v2/built-in-system-ppm/daily_report/for_create', {
        dailyDate: recordState.selectedDate,
      }).then((data) => {
        allHours.value = data.data.workHours;
      });
    } catch (error) {
      console.error('获取记录数据出现错误:', error);
    } finally {
      recordState.loadingShow = false;
    }
  }
  const allHours = ref(0);
  const subShow = ref(false);
  const editHour = ref(0);

  // 编辑日报
  function handlerEdit(item) {
    console.log(item, 'item');
  }
  const typeMap = {
    1: '任务日报',
    3: '其他日报',
    4: '项目日报',
    5: '行动项日报',
    6: '工单日报',
  };
</script>
<style lang="less" scoped>
  .page_root {
    box-sizing: border-box;
    min-height: 100%;
    background-image: url('http://10.40.0.33:9001/file-storage/540437262415247360-source.png');
    background-size: cover;
    padding: 40rpx;
  }

  .main {
    position: relative;
    height: calc(100vh - 340rpx);
    overflow: auto;
  }

  .record-date {
    display: flex;
    height: 80rpx;
    margin: 16rpx 0;
    font-size: 14rpx;
    color: #fff;
    padding: 20rpx 32rpx;
    background-image: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.6) 100%);
    border: 1px solid #fff;
    border-radius: 16rpx;
    position: relative;
    z-index: 10;
  }

  .date-left {
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.65);
    font-weight: 400;
  }

  .date-right {
    flex: 1;
    text-align: right;
    color: #008bff;
  }

  .record-body {
    height: 100%;
  }

  .edit-btn {
    font-size: 14px;
    color: rgba(53, 117, 199, 1);
  }

  .title-right {
    flex: 1;
    text-align: right;
  }

  .record-content {
    display: flex;
    flex-direction: column;
    font-size: 28rpx;
    position: relative;
    margin-bottom: 32rpx;
    border-radius: 16rpx;
    background-image: url('http://10.40.0.33:9001/file-storage/540472504740034560-source.png');
    background-size: cover;
  }

  .content-box {
    margin-bottom: 16px;
  }

  .content-box-top {
    padding: 24rpx 32rpx;
    display: flex;
    justify-content: space-between;
  }
  .top-left {
    display: flex;
    gap: 16rpx;
    align-items: center;
  }
  .daily-type {
    font-size: 36rpx;
    color: #ffffff;
    text-align: center;
    font-weight: 600;
  }
  .daily-status {
    height: 40rpx;
    text-align: center;
    border-radius: 8rpx;
    background: rgba(87, 180, 131, 0.2);
    border: 1px solid rgba(87, 180, 131, 1);
    font-size: 24rpx;
    color: #ffffff;
    text-align: center;
    font-weight: 400;
    padding: 1rpx 16rpx;
  }
  .daily-delete {
    height: 48rpx;
    width: 120rpx;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 1);
    text-align: center;
    font-size: 28rpx;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
  }

  .project-name {
    color: #00125e;
    letter-spacing: 0;
    line-height: 18px;
    font-weight: 600;
    white-space: nowrap;
    width: 60%;
  }

  .delete-btn {
    background: #008bff;
    border-radius: 2px;
    color: #fff;
    width: 58px;
    height: 24px;
    text-align: center;
    line-height: 24px;
  }

  .edit-tag {
    width: 10%;
  }

  .phase,
  .task-name,
  .task-time,
  .description,
  .risk,
  .solution,
  .risk-description {
    color: #8c8c8c;
    letter-spacing: 0;
    font-weight: 400;
  }

  .phase-content,
  .task-name-content,
  .task-time-content,
  .description-content,
  .risk-content,
  .solution-content,
  .risk-description-content {
    color: #262626;
    letter-spacing: 0;
    font-weight: 400;
  }

  .fixed-button {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    color: #fff;
    padding: 15px;
    text-align: center;
    border-radius: 8px;
    background-image: linear-gradient(-67deg, #82b0ff 0%, #3366ff 74%);
    font-size: 28rpx;
    color: #ffffff;
    font-weight: 500;
  }

  .no-data {
    width: 100%;
    text-align: center;
    color: #9fa0a0;
    position: absolute;
    top: 20%;
    width: 88px;
    height: 80px;
    left: 50%;
    transform: translate(-50%, 0);
  }

  .no-tip {
    position: absolute;
    top: 80px;
    left: 10px;
  }

  .content-item {
    padding: 15px;
    border-radius: 32rpx;
  }

  .item-bottom-title {
    margin: 4px 0;
    display: flex;
    align-items: center;
  }

  .item-bottom-title:nth-child(1) {
    margin-top: 0;
  }

  .work-title {
    width: 35%;
    font-size: 24rpx;
    color: rgba(0, 0, 0, 0.45);
    font-weight: 400;
    text-align: right;
  }

  .bottom-work-num {
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.85);
    font-weight: 400;
  }

  .no-confirm {
    width: 52px;
    height: 22px;
    background: #fff0e6;
    border: 1px solid #ff6800;
    border-radius: 4px;
    color: #ff6800;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
  }

  .ok-status {
    width: 52px;
    height: 22px;
    border: 1px solid #2979ff;
    border-radius: 4px;
    color: #2979ff;
    text-align: center;
    font-size: 12px;
    line-height: 20px;
  }

  .success-status {
    width: 52px;
    height: 22px;
    border: 1px solid #19be6b;
    border-radius: 4px;
    color: #19be6b;
    text-align: center;
    font-size: 12px;
    line-height: 20px;
  }

  .error-status {
    width: 52px;
    height: 22px;
    border: 1px solid #fa3534;
    border-radius: 4px;
    color: #fa3534;
    text-align: center;
    font-size: 12px;
    line-height: 20px;
  }

  .sub-title {
    padding: 0 5px;
  }
  .warp {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .rect {
    width: 120px;
    height: 120px;
    color: #fff;
  }
  .sub-title {
    padding: 0 15px;
    font-size: 14px;
  }
  :deep(.u-navbar) {
    background-color: transparent !important;
    padding: 0 40rpx 0 0;
    border: none;
  }
  :deep(.u-input) {
    background-color: #fff;
  }
</style>
